﻿using System.Collections;
using System.Collections.Generic;
using System;


namespace PBRSystem.Coord
{
    public class PBRNormal:PBRVector3
    {
        
        #region Contructor
        public PBRNormal():base()
        {
            
        }

        public PBRNormal(float x, float y, float z):base(x, y,z)
        {
            
        }

        public PBRNormal(PBRNormal normal)
        {
            X = normal.X;
            Y = normal.Y;
            Z = normal.Z;
        }
        #endregion

        #region Operation
        public PBRNormal FaceForward(PBRNormal n, PBRVector3 v)
        {
            float dotNV = Dot(n, v);
            if(dotNV < 0)
            {
                return -n;
            }
            return n;
        }
        #endregion

        #region Operator

        public static PBRNormal operator +(PBRNormal a, PBRNormal b)
        {
            return new PBRNormal(a.X + b.X, a.Y + b.Y, a.Z + b.Z);
        }

        public static PBRNormal operator -(PBRNormal a, PBRNormal b)
        {
            return new PBRNormal(a.X - b.X, a.Y - b.Y, a.Z - b.Z);
        }

        public static PBRNormal operator -(PBRNormal a)
        {
            return new PBRNormal(-a.X, -a.Y, -a.Z);
        }
        public static PBRNormal operator *(PBRNormal a, float s)
        {
            return new PBRNormal(a.X * s, a.Y * s, a.Z * s);
        }

        public static PBRNormal operator *(PBRNormal a, PBRNormal b)
        {
            return new PBRNormal(a.X * b.X, a.Y * b.Y, a.Z * b.Z);
        }

        public static PBRNormal operator /(PBRNormal a, PBRNormal b)
        {
            return new PBRNormal(a.X / b.X, a.Y / b.Y, a.Z / b.Z);
        }

        public static PBRNormal operator /(PBRNormal a, float s)
        {
            return new PBRNormal(a.X / s, a.Y / s, a.Z / s);
        }

        public static bool operator ==(PBRNormal a, PBRNormal b)
        {
            return (a.X == b.X) && (b.Y == b.Y) && (a.Z == b.Z);
        }
        public static bool operator !=(PBRNormal a, PBRNormal b)
        {
            return (a.X != b.X) && (a.Y != b.Y) && (b.Z != a.Z);
        }

        #endregion

        #region Override

        public override bool Equals(object obj)
        {
            if (!(obj is PBRNormal))
            {
                return false;
            }

            PBRNormal b = (PBRNormal)obj;

            return (X == b.X && Y == b.Y && Z == b.Z);
        }

        public override int GetHashCode()
        {
            return base.GetHashCode();
        }
        #endregion


    }
}


